import { http } from "@/utils/http";
import { URL_PREFIX } from "@/api/constants";
import type { HttpResponse } from "types/request";
import type { ContractData } from "@/types/contract.types";

/**
 * Search contracts by query string.
 * GET /api/v1/dnlab/refdata/search?q=...&limit=...
 */
export function searchContracts(params: { search: string; limit?: number }) {
  const { search, limit } = params;
  return http.request<HttpResponse<ContractData[]>>(
    "get",
    `${URL_PREFIX}/refdata/search`,
    {
      params: {
        search,
        limit: typeof limit === "number" ? limit : 20
      }
    }
  );
}
